package com.yalemang.tableview

import android.os.Bundle
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.yalemang.widget.tableview.TableAdapter
import com.yalemang.widget.tableview.TableTextAdapter
import com.yalemang.widget.tableview.TableView

class MainActivity : AppCompatActivity() {

    private lateinit var tableView: TableView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        tableView = findViewById(R.id.table_view)

        tableView.adapter = object : TableTextAdapter() {
            override fun showX(textView: TextView, position: Int) {
                textView.text = "X轴：${position}"
            }

            override fun showContent(textView: TextView, xPosition: Int, yPosition: Int) {
                textView.text = "($xPosition, $yPosition)"
            }

            override fun showY(textView: TextView, position: Int) {
                textView.text = "Y轴：${position}"
            }

            override fun getXCount(): Int {
                return 3
            }

            override fun getYCount(): Int {
                return 8
            }
        }
    }
}